<script type="text/javascript" src="/js/change.js" language="javascript" ></script>
<?php $util= new Util();?>
<?php if (isset($_SESSION['config_template'])) {?>
<?php if($_SESSION['config_template']=='layoutmain_web1')
			{?>
			<link rel="stylesheet" type="text/css" href="/css/web1/relative_faq.css" />
			<link rel="stylesheet" type="text/css" href="/css/web1/btn_all.css" />
			<link rel="stylesheet" type="text/css" href="/css/web1/faq.css" />
			<div class="col-main" id="main">
					<!-- start global messages -->
											<!-- end global messages -->

					<!-- start content -->
						<div id="messages_product_view"></div>
						<div class="page-title">
							<h1><?php echo $text_Question;?>
								<?php if(isset($permission) && $permission=="true") {?>
								<!-- Tạo cây bút chì cho click and change -->
								<ul class="gallery clearfix" style="width:30px;height:auto;float:left;margin-top:0;margin-left:5px;">
								<a style="border-bottom:0px dotted #aaa;" href="/questionanswer/edit/editqa?qaid=<?php echo $question["thing_id"]; ?>&amp;iframe=true&amp;width=370&amp;height=320" rel="prettyPhoto[iframe]">
									<img src="/images/Pencil.png" style="width:20px ; height:20px;margin-top:0;">
								</a>
								</ul>
								<input type="button" id="" onclick="delquestion('<?php echo $question['thing_id']; ?>','<?php echo $lag;?>')" value="" style="background-image: url('/images/button_del.png'); border: none; width:20px;height:20px;margin-top:0;">
								<!-- End - Tạo cây bút chì cho click and change -->
								<?php }?>
							</h1>
						</div>
							<div style="margin:0px;padding:0px;border:0px;" class="fieldset">
								<div id="aq">
								<div class="aq_row">
													<?php
															if (isset($question))
															{
																$question = $question;
																$username = "User invalid !";
																if (isset($user))
																{
																	$username = $user;
																} 
														?>
													<div class="aq_left">
														<div style="height:auto;width:auto;" class="avatar">
															<div class="user_info">
																<img onerror="this.src=\'/images/noimage.jpg\'" src="<?php echo $username["avatar"] ;?>" id="aq_user_img">
																<a title="Username" class="aq_user_name" id="aq_user_name"><?php echo  $username["user_name"] ?></a>
															</div>
														</div>
													</div>
													<div class="aq_right">
														<div class="description">
															<div class="aq_type">
																<span><h4><?php echo $question["title"];?></h4></span>
															</div>
															<style>  p {font-size:100% !important; } </style>
															<div style="font-size:15px; margin-left:10px;margin-right:5px;">
																<?php echo  str_replace("\\","",$question["description"]) ?>
															</div>			
															<div style="clear:both;margin-bottom:10px;"></div>
															
														</div>
														<div style="margin:0px" class="arrow">
															<div class="arrow_img"></div>
														</div>
														<div class="question_info">
														
															<div class="q_info">
															<img onclick="addLike(<?php echo $_GET['id'];?>)" style="float:left;width:14px;" src="../images/thumb_up.gif" class="btn">
																<span style="float:right;color:green;" class="aq_span_date" id="aq_span_date">
																<div style="float:right;margin-left:5px;" id="num_like"><?php echo $CountLike?></div>
																</span>
															</div>
															<div class="q_info">
																<span class="aq_span_date" id="aq_span_date"><?php echo $text_views?> <?php echo $question["views"]?></span>
															</div>
															<div class="q_info">
																<span class="aq_span_date" id="aq_span_date"><?php echo $text_answer?> <?php echo $CountComment?></span>
															</div>
															<div style="clear:both;margin-left:5px;">
															
															<span class="aq_span_date" id="aq_span_date"><?php echo $text_post?> <?php echo $util->makeDays($question["update_date"])?></span>
															</div>
														</div>
													</div>
												</div>
								</div>
							</div>
							<div style="clear:both;"></div>
							<div style="padding-top:10px;margin-top:20px;" class="buttons-set">
								<input type="text" style="display:none !important;" value="" id="hideit" name="hideit">
							</div>
						<script type="text/javascript">
						//&lt;![CDATA[
							var contactForm = new VarienForm('contactForm', true);
						//]]&gt;
						</script>
						&nbsp;
					<!-- end content -->
						<?php } ?>
			</div>
					
			<?php }else if($_SESSION['config_template']=='layoutmain_web2') { ?>
<link rel="stylesheet" type="text/css" href="/css/web2/questionanswer.css" />
<!--Question Answer-->
<div class="page-title">
    <h1><span style="color: #EA2E9D;font-size: 24px;"><?php echo $text_Question;?></span>
						<?php if(isset($permission) && $permission=="true") {?>
						<div style="float:right;">
						<!-- Tạo cây bút chì cho click and change -->
						<ul class="gallery clearfix" style="width:30px;height:auto;float:left;margin-top:0;margin-left:5px;">
						<a style="border-bottom:0px dotted #aaa;" href="/questionanswer/edit/editqa?qaid=<?php echo $question["thing_id"]; ?>&amp;iframe=true&amp;width=370&amp;height=320" rel="prettyPhoto[iframe]">
							<img src="/images/Pencil.png" style="width:20px;height:20px;margin-top:0;">
						</a>
						</ul>
						<input type="button" id="" onclick="delquestion('<?php echo $question['thing_id']; ?>','<?php echo $lag;?>')" value="" style="background-image: url('/images/button_del.png'); border: none; width:20px;height:20px;margin-top:0;cursor: pointer;">
						</div>
						<!-- End - Tạo cây bút chì cho click and change -->
						<?php }?>    
    </h1>
</div>
					<?php
					if (isset($question))
					{
						$question = $question;
						$username = "User invalid !";
						if (isset($user))
						{
							$username = $user;
						} 
					?>
		<div id="aq">
			<div class="aq_row">
				<div class="aq_left">
					<div class="avatar" style="height:auto;width:auto;">
						<div class="user_info">
							<img id="aq_user_img" src="<?php echo $username["avatar"] ;?>" onerror="this.src=\'/images/noimage.jpg\'"/>
							<a id="aq_user_name" class="aq_user_name" title="Username" style="color: #ED239A;font-weight: normal;text-decoration: none;"><?php echo $username["user_name"] ;?></a>
						</div>
					</div>
				</div>
				<div class="aq_right">
					<div class="description" style="background:#F8F8F8;">
						<div class="aq_type">
							<span><h4><?php echo $question["title"];?></h4></span>
						</div>
						<style>  p {font-size:100% !important; } </style>
						<div style="font-size:13px; margin-left:10px;margin-right:5px;">
							<?php echo  str_replace("\\","",$question["description"]) ?>
						</div>			
						<div style="clear:both;margin-bottom:10px;"></div>
						
					</div>
					<div class="arrow" style="margin:0px">
						<div class="arrow_img"></div>
					</div>
					<div class="question_info">
					
						<div class="q_info">
						<img class="btn" src="../images/thumb-up.png" style="float:left;width:14px;" onclick="addLike(<?php echo $_GET['id'];?>)">
							<span id="aq_span_date" class="aq_span_date" style="float:right;color:green;">
							<div id="num_like" style="float:right;margin-left:5px;"><?php echo $CountLike?></div>
							</span>
						</div>
						<div class="q_info">
							<span id="aq_span_date" class="aq_span_date"><?php echo $text_views?> <?php echo $question["views"]?></span>
						</div>
						<div class="q_info">
							<span id="aq_span_date" class="aq_span_date"><?php echo $text_answer?> <?php echo $CountComment?></span>
						</div>
						<div style="clear:both;margin-left:5px;">
						
						<span id="aq_span_date" class="aq_span_date"><?php echo $text_post?> <?php echo $util->makeDays($question["update_date"])?></span>
						</div>
					</div>
				</div>
			</div>		
			<div style="clear: both;"></div>
		</div>
		<?php }?>
<!--End Question Answer-->
<?php } else { ?>
<link rel="stylesheet" type="text/css" href="/css/relative_faq.css" />
<link rel="stylesheet" type="text/css" href="/css/btn_all.css" />
<link rel="stylesheet" type="text/css" href="/css/faq.css" />
				<div style="clear:both;"></div>
				<div id="aq">
					<div>
						<div style="float:left;"><?php echo $text_Question;?></div>
						<?php if(isset($permission) && $permission=="true") {?>
						<!-- Tạo cây bút chì cho click and change -->
						<ul class="gallery clearfix" style="width:30px;height:auto;float:left;margin-top:0;margin-left:5px;">
						<a style="border-bottom:0px dotted #aaa;" href="/questionanswer/edit/editqa?qaid=<?php echo $question["thing_id"]; ?>&amp;iframe=true&amp;width=370&amp;height=320" rel="prettyPhoto[iframe]">
							<img src="/images/Pencil.png" style="width:20px;height:20px;margin-top:0;">
						</a>
						</ul>
						<input type="button" id="" onclick="delquestion('<?php echo $question['thing_id']; ?>','<?php echo $lag;?>')" value="" style="background-image: url('/images/button_del.png'); border: none; width:20px;height:20px;margin-top:0;">
						<!-- End - Tạo cây bút chì cho click and change -->
						<?php }?>
						<div class="line"><hr></div>
					</div>
					<?php
					if (isset($question))
					{
						$question = $question;
						$username = "User invalid !";
						if (isset($user))
						{
							$username = $user;
						} 
					?>
						<div class="aq_row">
							<div class="aq_left">
								<div class="avatar" style="height:auto;width:auto;">
									<div class="user_info">
										<img id="aq_user_img" src="<?php echo $username["avatar"] ;?>" onerror="this.src=\'/images/noimage.jpg\'"/>
										<a id="aq_user_name" class="aq_user_name" title="Username"><?php echo  $username["user_name"] ?></a>
									</div>
								</div>
							</div>
							<div class="aq_right">
								<div class="description">
									<div class="aq_type">
										<span><h4><?php echo $question["title"];?></h4></span>
									</div>
									<style>  p {font-size:100% !important; } </style>
									<div style="font-size:15px; margin-left:10px;margin-right:5px;">
										<?php echo  str_replace("\\","",$question["description"]) ?>
									</div>			
									<div style="clear:both;margin-bottom:10px;"></div>
									
								</div>
								<div class="arrow" style="margin:0px">
									<div class="arrow_img"></div>
								</div>
								<div class="question_info">
								
									<div class="q_info">
									<img class="btn" src="../images/thumb-up.png" style="float:left;width:14px;" onclick="addLike(<?php echo $_GET['id'];?>)">
										<span id="aq_span_date" class="aq_span_date" style="float:right;color:green;">
										<div id="num_like" style="float:right;margin-left:5px;"> <?php echo $CountLike?></div>
										</span>
									</div>
									<div class="q_info">
										<span id="aq_span_date" class="aq_span_date"><?php echo $text_views?> <?php echo $question["views"]?></span>
									</div>
									<div class="q_info">
										<span id="aq_span_date" class="aq_span_date"><?php echo $text_answer?> <?php echo $CountComment?></span>
									</div>
									<div style="clear:both;margin-left:5px;">
									
									<span id="aq_span_date" class="aq_span_date"><?php echo $text_post?> <?php echo $util->makeDays($question["update_date"])?></span>
									</div>
								</div>
							</div>
						</div>
						<p>&nbsp;</p>
						<div id="aq_caption">
							<p><?php echo $text_Comment?></p>
						</div>
					<?php } ?>
				</div>
 <?php }} ?>				
				<div style="clear: both;"></div>
<script type="text/javascript">
function delquestion(id,lag)
{ 
	var cf="Bạn có chắc muốn xóa câu hỏi này?";
	if(lag=="en")
		cf="Are you sure to delete this question?";
	var confirmed=confirm(cf);
	if(confirmed==true)
	{
		var _id=id;
	
		if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp=new XMLHttpRequest();
		
		}
		else
		{// code for IE6, IE5
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange = function()
		{	if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
				
				var str = xmlhttp.responseText;
				//alert(str);return;
				if(str==-1)
				{
					if(lag=="en")
						alert("Delete fail!");
					else
						alert("Xóa thất bại!");
				}
				else if(str==-2)
				{
					if(lag=="en")
						alert("Can not find question!");
					else
						alert("Không tìm thấy câu hỏi!");
				}
				else if(str==-3)
				{
					if(lag=="en")
						alert("You dont have permission to do this!");
					else
						alert("Bạn không có quyền thực hiện thao tác này!");
				}
				else 
				{
					var url = "/qa/category";
					if(lag=="en")
						alert("Delete success!");
					else
						alert("Xóa thành công!");
					window.location=url;
				}
			}
		};
	
		var url = "/questionanswer/delete?id="+_id;
		xmlhttp.open("GET",url,true);	
		xmlhttp.send();
		return false;
	}
}
</script>
